﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace PopShops.Entities
{
    public class Merchant
    {
        #region Public Properties

        [XmlAttribute("id")]
        public int MerchantID { get; set; }
        [XmlAttribute("network_id")]
        public string network_id { get; set; }
        [XmlAttribute("name")]
        public string Name { get; set; }
        [XmlAttribute("url")]
        public string Url { get; set; }
        [XmlAttribute("logo_url")]
        public string LogoUrl { get; set; }
        [XmlAttribute("deal_count")]
        public string DealCount { get; set; }
        [XmlAttribute("product_count")]
        public string ProductCount { get; set; }

        public int NetworkID
        {
            get
            {
                if (string.IsNullOrEmpty(network_id))
                    return 0;

                return int.Parse(network_id);
            }
        }

        [XmlAttribute("network_merchant_id")]
        public string NetworkMerchantID { get; set; }

        [XmlAttribute("merchant_type_id")]
        public int MerchantTypeID { get; set; }

        #endregion

        #region Ctor

        public Merchant()
        { }

        public Merchant(int id, string name, string network_id, string logo_url, string url, string network_merchant_id)
        {
            this.MerchantID = id;
            this.network_id = network_id;
            this.Name = name;
            this.Url = url;
            this.LogoUrl = logo_url;
            this.NetworkMerchantID = network_merchant_id;
        }

        #endregion
    }

    [XmlRoot("merchants")]
    public class Merchants
    {
        public Merchants()
        { }

        [XmlAttribute("total_count")]
        public long TotalCount { get; set; }

        [XmlElement("merchant")]
        public List<Merchant> MerchantCollection { get; set; }
    }
}
